#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "func.h"

char fileName[1024];
int a_flag = 0;
int l_flag = 0;

int flag_of_mulDir = 0;

int main(int argc, char **argv) {
    int opt;
    while ( (opt = getopt(argc, argv, "al")) != -1 ) {
        switch (opt) {
            case 'a':
                // printf("a found!\n");
                a_flag = 1;
                break;
            case 'l':
                // printf("b found!\n");
                l_flag = 1;
                break;
            default:
                fprintf(stderr, "Usage : %s -al\n", argv[0]);
                exit(1);
        }
    }
    // printf("argc = %d\n", argc);
    if (argc == optind) {
        char buff[1024];
        getcwd(buff, sizeof(buff));
        ls_all_file(buff);
        return 0;
    }
    if (argc - optind > 1) {
        flag_of_mulDir = 1;
    }
    for (int i = optind; i < argc; i++) {
        // printf(GREEN("%d = %s\n"), i, argv[i]);
        ls_all_file(argv[i]);
        // printf("%d = %s\n", i, argv[i]);
    }

    return 0;
}